<?php
/**
 * (exporter)
 */
namespace App\Exporter\Delivery;

use App\Models\Basics\SysPlat;
use App\Models\Delivery\DeliveryReview;
use App\Util\User;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\WithMapping;

class DeliveryViewExporter extends ExcelExporter implements WithMapping, ShouldQueue{

    protected $fileName = '发货需求文件.csv';

    protected $headings = ['平台','类型','需求文件名','标签文件名','销售','状态','创建时间'];

    public function map($model) : array
    {
        return [
            SysPlat::getSysPlatTitle($model->plat_id) ?? '',
            DeliveryReview::$_type[$model->type] ?? '',
            $model->file_name ?? '',
            $model->tag_name ?? '',
            User::getUsernameById($model->seller_id) ?? '',
            DeliveryReview::$_status[$model->status] ?? '',
            $model->created_at,
        ];
    }
}
